function checkUser() {
	var user = document.getElementById("username").value;
	var userTip = document.getElementById("usernameMsg")
	
	if(user.length == 0) {
		userTip.innerHTML = "请输入用户名！";
		userTip.style.color="red"
		return false;
	} else {
		userTip.innerHTML = " ";
		userTip.style.color="green"
		return true;
	}
}

function checkPwd() {
	var pwd = document.getElementById("password").value;
	var pwdTip = document.getElementById("passwordMsg");
	var count = pwd.length;
	for(i = 0; i < pwd.length; i++) {
		var e = pwd.charAt(i);
		if(e > '0' && e < '9') {
			count--;
			continue;
		}
	}
	if(pwd.length < 8) {
		pwdTip.innerHTML = "密码长度不可小于8位！";
		pwdTip.style.color="red"
		return false;
	}
	if(count == 0) {
		pwdTip.innerHTML = "密码不可为纯数字！";
		pwdTip.style.color="red"
		return false;
	} else {
		pwdTip.innerHTML = " ";
		pwdTip.style.color="green"
		return true;
	}
}

function checkPwd2() {
	var pwd = document.getElementById("password").value;
	var pwd2 = document.getElementById("password2").value;
	var pwd2Tip = document.getElementById("password2Msg");
	if(pwd==null){
		pwd2Tip.innerHTML = "请先输入密码！";
		pwd2Tip.style.color="red"
	}else{
		if(pwd == pwd2) {
			pwd2Tip.innerHTML = " ";
			pwd2Tip.style.color="green"
			return true;

		} else {
			pwd2Tip.innerHTML = "两次输入密码不一致！";
			pwd2Tip.style.color="red"
			return false;
		}
	}

}

function checkCode() {
	var code = document.getElementById("code").value;
	var codeTip = document.getElementById("codeMsg");
	if(code == "") {
		codeTip.innerHTML = "验证码不能为空！";
		codeTip.style.color="red"
		return false;
	} else {
		codeTip.innerHTML = "";
		return true;
	}
}

function checkAll() {
	if(checkUser() && checkPwd() && checkPwd2() && checkCode()) {
		return true;
	} else {
		return false;
	}
}